/**
 * @param {string} s
 * @return {boolean}
 */
var checkRecord = function (s) {
  let res = true
  let countA=0,countL=0
  if(s[0]=='A'){
    countA++
  }else if(s[0]=='L'){
    countL++
  }
  for(let i=1;i<s.length;i++){
    if(s[i]=='P')continue
    else if(s[i]=='A'){
      if(countA){
        res=false
        break
      }else countA++
    }else {
      if(s[i-1]=='L'){
        countL++
        if(countL==3){
          res=false
          break
        }
      }else {
        countL=1
      }
    }
  }

  return res
};